package product;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.*;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.lang.reflect.Array;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

public class ProductMain4 extends JInternalFrame {

	ProductInput pInput = null;
	ProductUpdate pUpdate = null;
	
	CompanyInput csInput = null;
	CompanyUpdate cpUpdate = null;
	
	DeliveryInput dInput = null;
	DeliveryUpdate dUpdate = null;
	
	DeliveryStock ds = null;
	DeliveryRecall dr = null;
	DeliveryRecallUpdate dru = null;
	DeliveryList dl = null;
	
	TotalList tList = null;
	
	JDesktopPane contentPane;
	Connection conn;

	private JMenuBar menuBar;
	private JMenu mnNewMenu;
	private JMenuItem mntmNewMenuItem_1;
	private JMenuItem mntmNewMenuItem_2;
	private JMenu mnNewMenu_1;
	private JMenuItem mntmNewMenuItem_3;
	private JMenu mnNewMenu_2;
	private JMenuItem mntmInsertReturnData;
	private JMenuItem mntmNewMenuItem_5;
	private JMenuItem mntmNewMenuItem;
	private JMenu mnNewMenu_3;
	private JMenuItem mntmNewMenuItem_4;
	private JMenuItem mntmNewMenuItem_6;
	private JMenu mnNewMenu_4;
	private JMenuItem mntmNewMenuItem_7;
	private JMenuItem mntmNewMenuItem_8;
	private JMenuItem mntmNewMenuItem_9;
	private JMenuItem mntmNewMenuItem_11;
	private JMenuItem mntmNewMenuItem_10;

	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ProductMain4 frame = new ProductMain4();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	public ProductMain4() {
		super("4조-Supply Chain Management", true, true, true, false);
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
			SwingUtilities.updateComponentTreeUI(this);
			
			OracleJdbc o = new OracleJdbc();
			conn = o.conn;

		} catch (Exception e) {}
		
		setBounds(10, 40, 1580, 769);
		setJMenuBar(getMenuBar_1());
		contentPane = new JDesktopPane();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

	}
	public void openProductInput(){
		if(pInput == null){
			pInput = new ProductInput(this);
			contentPane.add(pInput);
		}
		pInput.setVisible(true);
		pInput.toFront();
	}
	public void openProductUpdate(){
		if(pUpdate == null){
			pUpdate = new ProductUpdate(this);
			contentPane.add(pUpdate);
		}
		pUpdate.setVisible(true);
		pUpdate.toFront();
	}
	public void openCompanyInput(){
		if(csInput == null){
			csInput = new CompanyInput(this);
			contentPane.add(csInput);
		}
		csInput.setVisible(true);
		csInput.toFront();
	}
	public void openCompanyUpdate(){
		if(cpUpdate == null){
			cpUpdate = new CompanyUpdate(this);
			contentPane.add(cpUpdate);
		}
		cpUpdate.setVisible(true);
		cpUpdate.toFront();
	}
	public void openDeliveryInput(){
		if(dInput == null){
			dInput = new DeliveryInput(this);
			contentPane.add(dInput);
		}
		dInput.setVisible(true);
		dInput.toFront();
	}
	public void openDeliveryUpdate(){
		if(dUpdate == null){
			dUpdate = new DeliveryUpdate(this);
			contentPane.add(dUpdate);
		}
		dUpdate.setVisible(true);
		dUpdate.toFront();
	}
	public void OpenDeliveryStock(){
		if (ds == null){
			ds = new DeliveryStock(this);
			contentPane.add(ds);
		}
		ds.setVisible(true);
		ds.toFront();
	}
	
	public void OpenDeliveryRecall(){
		if(dr == null){
			dr = new DeliveryRecall(this);
			contentPane.add(dr);
		}
		dr.setVisible(true);
		dr.toFront();
	}
	
	public void OpenDeliveryRecallUpdate(){
		if(dru == null){
			dru = new DeliveryRecallUpdate(this);
			contentPane.add(dru);
		}
		dru.setVisible(true);
		dru.toFront();
	}
	
	public void openList(){
		if(tList == null){
			tList = new TotalList(this);
			contentPane.add(tList);
		}
		tList.setVisible(true);
		tList.toFront();
	}
	
	public void openDeliveryList(){
		if(dl == null){
			dl = new DeliveryList(this);
			contentPane.add(dl);
		}
		dl.setVisible(true);
		dl.toFront();
	}
	
	private JMenuBar getMenuBar_1() {
		if (menuBar == null) {
			menuBar = new JMenuBar();
			menuBar.add(getMnNewMenu());
			menuBar.add(getMnNewMenu_1());
			menuBar.add(getMnNewMenu_3());
			menuBar.add(getMnNewMenu_2());
			menuBar.add(getMnNewMenu_4());
		}
		return menuBar;
	}

	private JMenu getMnNewMenu() {
		if (mnNewMenu == null) {
			mnNewMenu = new JMenu("Customer");
			mnNewMenu.add(getMntmNewMenuItem_1());
			mnNewMenu.add(getMntmNewMenuItem_2());
			mnNewMenu.add(getMntmNewMenuItem_8());
		}
		return mnNewMenu;
	}

	private JMenuItem getMntmNewMenuItem_1() {
		if (mntmNewMenuItem_1 == null) {
			mntmNewMenuItem_1 = new JMenuItem("Insert Customer Data");
			mntmNewMenuItem_1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openCompanyInput();
				}
			});
		}
		return mntmNewMenuItem_1;
	}

	private JMenuItem getMntmNewMenuItem_2() {
		if (mntmNewMenuItem_2 == null) {
			mntmNewMenuItem_2 = new JMenuItem("Modify Customer Data");
			mntmNewMenuItem_2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openCompanyUpdate();
				}
			});
		}
		return mntmNewMenuItem_2;
	}

	private JMenu getMnNewMenu_1() {
		if (mnNewMenu_1 == null) {
			mnNewMenu_1 = new JMenu("Supply");
			mnNewMenu_1.add(getMntmNewMenuItem_3());
			mnNewMenu_1.add(getMntmNewMenuItem());
			mnNewMenu_1.add(getMntmNewMenuItem_9());
		}
		return mnNewMenu_1;
	}

	private JMenuItem getMntmNewMenuItem_3() {
		if (mntmNewMenuItem_3 == null) {
			mntmNewMenuItem_3 = new JMenuItem("Insert Supply Data");
			mntmNewMenuItem_3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openProductInput();
				}
			});

		}
		return mntmNewMenuItem_3;
	}
	private JMenu getMnNewMenu_2() {
		if (mnNewMenu_2 == null) {
			mnNewMenu_2 = new JMenu("Return");
			mnNewMenu_2.add(getMntmInsertReturnData());
			mnNewMenu_2.add(getMntmNewMenuItem_10());
			mnNewMenu_2.add(getMntmNewMenuItem_11());
		}
		return mnNewMenu_2;
	}
	private JMenuItem getMntmInsertReturnData() {
		if (mntmInsertReturnData == null) {
			mntmInsertReturnData = new JMenuItem("Insert Return Data");
			mntmInsertReturnData.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					OpenDeliveryRecall();
				}
			});
		}
		return mntmInsertReturnData;
	}
	private JMenuItem getMntmNewMenuItem_5() {
		if (mntmNewMenuItem_5 == null) {
			mntmNewMenuItem_5 = new JMenuItem("Search Delivery Stock");
			mntmNewMenuItem_5.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					OpenDeliveryStock();
				}
			});
		}
		return mntmNewMenuItem_5;
	}
	private JMenuItem getMntmNewMenuItem() {
		if (mntmNewMenuItem == null) {
			mntmNewMenuItem = new JMenuItem("Modify Supply Data");
			mntmNewMenuItem.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openProductUpdate();
				}
			});
		}
		return mntmNewMenuItem;
	}
	private JMenu getMnNewMenu_3() {
		if (mnNewMenu_3 == null) {
			mnNewMenu_3 = new JMenu("Delivery");
			mnNewMenu_3.add(getMntmNewMenuItem_4());
			mnNewMenu_3.add(getMntmNewMenuItem_6());
			mnNewMenu_3.add(getMntmNewMenuItem_5());
		}
		return mnNewMenu_3;
	}
	private JMenuItem getMntmNewMenuItem_4() {
		if (mntmNewMenuItem_4 == null) {
			mntmNewMenuItem_4 = new JMenuItem("Insert Delivery Data");
			mntmNewMenuItem_4.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openDeliveryInput();
				}
			});
		}
		return mntmNewMenuItem_4;
	}
	private JMenuItem getMntmNewMenuItem_6() {
		if (mntmNewMenuItem_6 == null) {
			mntmNewMenuItem_6 = new JMenuItem("Modify Delivery Data");
			mntmNewMenuItem_6.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openDeliveryUpdate();
				}
			});
		}
		return mntmNewMenuItem_6;
	}
	private JMenu getMnNewMenu_4() {
		if (mnNewMenu_4 == null) {
			mnNewMenu_4 = new JMenu("Etc");
			mnNewMenu_4.add(getMntmNewMenuItem_7());
		}
		return mnNewMenu_4;
	}
	private JMenuItem getMntmNewMenuItem_7() {
		if (mntmNewMenuItem_7 == null) {
			mntmNewMenuItem_7 = new JMenuItem("All Search");
			mntmNewMenuItem_7.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openList();
				}
			});
		}
		return mntmNewMenuItem_7;
	}
	private JMenuItem getMntmNewMenuItem_8() {
		if (mntmNewMenuItem_8 == null) {
			mntmNewMenuItem_8 = new JMenuItem("Search Customer Data");
			mntmNewMenuItem_8.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openList();
					tList.getComboBox_1().setSelectedItem("거래처");
					tList.searchData();
				}
			});
		}
		return mntmNewMenuItem_8;
	}
	private JMenuItem getMntmNewMenuItem_9() {
		if (mntmNewMenuItem_9 == null) {
			mntmNewMenuItem_9 = new JMenuItem("Search Supply Data");
			mntmNewMenuItem_9.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openList();
					tList.getComboBox_1().setSelectedItem("생산");
					tList.searchData();
				}
			});
		}
		return mntmNewMenuItem_9;
	}
	private JMenuItem getMntmNewMenuItem_11() {
		if (mntmNewMenuItem_11 == null) {
			mntmNewMenuItem_11 = new JMenuItem("Search Return Data");
			mntmNewMenuItem_11.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					openList();
					tList.getComboBox_1().setSelectedItem("반품");
					tList.searchData();
				}
			});
		}
		return mntmNewMenuItem_11;
	}
	private JMenuItem getMntmNewMenuItem_10() {
		if (mntmNewMenuItem_10 == null) {
			mntmNewMenuItem_10 = new JMenuItem("Modify Return Data");
			mntmNewMenuItem_10.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					OpenDeliveryRecallUpdate();
				}
			});
		}
		return mntmNewMenuItem_10;
	}
}
